"""
@file: share.py
@author: yangsiting
@data: 2021/04/27
@desc:
"""
from .base import db
import datetime
from .user import UserProfile

now1 = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

class ShareInfo(db.Model):
    __tablename__ = "share_info"
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_profile_id = db.Column(db.ForeignKey('user_profile.user_profile_id'))
    share_message = db.Column(db.Text)
    share_img = db.Column(db.Text)
    create_time = db.Column(db.String)

    @classmethod
    def create_share(cls,user_profile_id,share_message,share_img):
        info = cls()
        info.user_profile_id= user_profile_id
        info.share_message = share_message
        info.share_img = share_img
        info.create_time = now1
        db.session.add(info)
        db.session.commit()
